package com.ecarx.engineermode.tab.model;

import java.util.ArrayList;
import java.util.List;

public class TabItem {
    GroupItem groupItem;
    List<ChildItem> childItemList;

    public TabItem(Builder builder) {
        childItemList = builder.childItemList;
        groupItem = builder.groupItem;
    }

    public GroupItem getGroupItem() {
        return groupItem;
    }

    public List<ChildItem> getChildItemList() {
        return childItemList;
    }

    public boolean isOnlyGroup() {
        return childItemList == null || childItemList.isEmpty();
    }

    public static class Builder {

        GroupItem groupItem;
        List<ChildItem> childItemList = new ArrayList<>();

        public Builder setGroupItem(GroupItem groupItem) {
            this.groupItem = groupItem;
            return this;
        }

        public Builder addChildItem(ChildItem childItem) {
            childItemList.add(childItem);
            return this;
        }

        public TabItem build() {
            return new TabItem(this);
        }
    }
}